#include "stdafx.h"
#include "adodb_impl.h"

ADODB::ADODB() : impl_(new Impl) {}

ADODB::~ADODB()
{
	delete impl_;
	impl_ = NULL;
}

bool ADODB::Connect(const wchar_t* ip, const wchar_t* db, const wchar_t* user, const wchar_t* password, unsigned long timeout)
{
	return impl_->Connect(ip, db, user, password, timeout);
}

bool ADODB::Connect(const wchar_t* connection_string, unsigned long timeout)
{
	return impl_->Connect(connection_string, timeout);
}

bool ADODB::Disconnect()
{
	return impl_->Disconnect();
}

bool ADODB::SetCommand(CommandType type, const wchar_t* sql, unsigned long timeout)
{
	return impl_->SetCommand(type, sql, timeout);
}

bool ADODB::SetParameter(const wchar_t* column, ParameterDirection direction, DataType type, const void* data, std::size_t size)
{
	return impl_->SetParameter(column, direction, type, const_cast<void*>(data), size);
}

bool ADODB::SetParameter(short column, ParameterDirection direction, DataType type, const void* data, std::size_t size)
{
	return impl_->SetParameter(column, direction, type, const_cast<void*>(data), size);
}

bool ADODB::ExecuteCommand()
{
	return impl_->ExecuteCommand();
}

/*
bool ADODB::GetRowCount(unsigned long& count)
{
	return impl_->GetRowCount(count);
}

bool ADODB::GetRowSize(std::size_t& size)
{
	return impl_->GetRowSize(size);
}
*/

bool ADODB::GetColumnCount(short& count)
{
	return impl_->GetColumnCount(count);
}

bool ADODB::GetColumnType(short column, DataType& type)
{
	return impl_->GetColumnType(_variant_t(column), type);
}

bool ADODB::GetColumnType(const wchar_t* column, DataType& type)
{
	return impl_->GetColumnType(_variant_t(column), type);
}

bool ADODB::GetColumnActualSize(short column, std::size_t& size)
{
	return impl_->GetColumnActualSize(_variant_t(column), size);
}

bool ADODB::GetColumnActualSize(const wchar_t* column, std::size_t& size)
{
	return impl_->GetColumnActualSize(_variant_t(column), size);
}

bool ADODB::GetColumnDefinedSize(short column, std::size_t& size)
{
	return impl_->GetColumnDefinedSize(_variant_t(column), size);
}

bool ADODB::GetColumnDefinedSize(const wchar_t* column, std::size_t& size)
{
	return impl_->GetColumnDefinedSize(_variant_t(column), size);
}

bool ADODB::GetColumnData(short column, DataType type, void* buffer, std::size_t buffer_size, std::size_t* actual_size)
{
	return impl_->GetColumnData(_variant_t(column), type, buffer, buffer_size, actual_size);
}

bool ADODB::GetColumnData(const wchar_t* column, DataType type, void* buffer, std::size_t buffer_size, std::size_t* actual_size)
{
	return impl_->GetColumnData(_variant_t(column), type, buffer, buffer_size, actual_size);
}

bool ADODB::SetCursorLocation(CursorLocation location)
{
	return impl_->SetCursorLocation(location);
}

bool ADODB::IsRowEnd()
{
	return impl_->IsRowEnd();
}

bool ADODB::MoveNextRow()
{
	return impl_->MoveNextRow();
}

bool ADODB::IsConnected() const
{
	return impl_->IsConnected();
}